"""截图处理"""
import datetime
import os


from selenium.webdriver import Chrome
from config import SCREENSHOTDIR

# @staticmethod
def screenshots(driver:Chrome):
    # img_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),"screenshot") #保存截图的路径
    filename = str(datetime.datetime.now().strftime("%Y%m%d%H%M%S"))+".png" #截图的命名
    file = os.path.join(SCREENSHOTDIR,filename)
    driver.save_screenshot(file)
    return file
#
# from selenium import webdriver
# import time
# driver = webdriver.Chrome()
# driver.get("https://www.baidu.com/")
# time.sleep(2)
# screenshots(driver)
# time.sleep(2)
# driver.quit()

